import { showLoadingToast } from 'vant';
export function useLoading() {
	let toast: any = null;

	const startLoading = (loadingText: string = 'Loading...') => {
		toast = showLoadingToast({
			duration: 0,
			forbidClick: true,
			message: loadingText,
		});
	};
	const stopLoading = () => {
		toast && toast.close();
	};

	onBeforeUnmount(stopLoading);

	return { startLoading, stopLoading };
}
